package com.example.teesystem.mapper;

import com.example.teesystem.entity.Exam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
* @author NieYaShi
* @description 针对表【t_exam】的数据库操作Mapper
* @createDate 2022-04-15 14:57:54
* @Entity com.example.teesystem.entity.Exam
*/
@Mapper
public interface ExamMapper extends BaseMapper<Exam> {
    @Select("select * from t_exam where paper_id = #{paperId} and student_id = #{studentId}")
    List<Exam> getExamsByPaperIdAndStudentId(int paperId, int studentId);

    @Select("select * from t_exam where paper_id = #{paperId} and issue_id = #{issueId} and student_id = #{studentId}")
    Exam getExamByPaperIssueAndStudentId(int paperId, int issueId, int studentId);

    @Select("select SUM(score) FROM t_exam WHERE paper_id = #{paperId} AND student_id = #{studentId}")
    int summaryScore(int paperId, int studentId);

    @Select("select * from t_exam where paper_id = #{paperId}")
    List<Exam> getExamByPaperId(int paperId);

    @Select("select student_id from t_exam where paper_id = #{paperId}")
    Set<Integer> getStudentIdById(int paperId);

    @Select("select * from t_exam where paper_id = #{paperId} and student_id = #{studentId} and is_mark = 0")
    List<Exam> check(int paperId, int studentId);
}




